import 'package:flutter/material.dart';
import 'package:flutter_taotaoshipin/common/theme/app_colors.dart';
import 'package:flutter_taotaoshipin/util/theme_utils.dart';

/// 顶部 tab 切换
class MyTab extends StatelessWidget {
  final List<Widget> tabs;
  final TabController? controller;
  final double? fontSize;
  final double? unselFontSize;
  final double borderWidth;
  final Color? labelColor;
  final Color? unselectedLabelColor;

  const MyTab(this.tabs,
      {super.key,
      this.controller,
      this.fontSize,
      this.borderWidth = 2,
      this.unselFontSize,
      this.labelColor,
      this.unselectedLabelColor});

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.transparent,
      child: Container(
        width: double.infinity,
        child: TabBar(
          controller: controller,
          isScrollable: true,
          labelColor: labelColor,
          unselectedLabelColor: unselectedLabelColor,
          labelStyle: TextStyle(
            fontSize: fontSize,
            fontWeight: FontWeight.w900,
          ),
          // indicator: BoxDecoration(),
          indicator: UnderlineTabIndicator(
            borderRadius: BorderRadius.circular(5),
            borderSide:
                BorderSide(color: AppColors.app_main, width: borderWidth),
            insets: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
          ),
          indicatorSize: TabBarIndicatorSize.label,
          unselectedLabelStyle: TextStyle(
            fontSize: unselFontSize,
            fontWeight: FontWeight.w900,
          ),
          tabs: tabs,
        ),
      ),
    );
  }
}
